﻿<phone:PhoneApplicationPage x:Class="DepSoft.Mobile.WP7.FollwIt.View.CollectionPage"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                            xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
                            xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                            xmlns:wp7contribcontrolbehaviors="clr-namespace:WP7Contrib.View.Controls.Behaviors;assembly=WP7Contrib.View.Controls"
                            xmlns:gsextra="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP71"                            
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:DepSoftFollwItFramework="clr-namespace:DepSoft.Mobile.WP7.FollwIt.Framework"
                            mc:Ignorable="d"
                            d:DesignWidth="480"
                            d:DesignHeight="696"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            SupportedOrientations="Portrait"
                            Orientation="Portrait"
                            shell:SystemTray.IsVisible="True"
                            DataContext="{Binding CollectionViewModel, Source={StaticResource Locator}}">

    <phone:PhoneApplicationPage.Resources>
        <ItemsPanelTemplate x:Key="ItemsPanelTemplate">
            <toolkit:WrapPanel/>
        </ItemsPanelTemplate>
    </phone:PhoneApplicationPage.Resources>

    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator x:Name="progressOverlay"
                                 IsIndeterminate="{Binding ProgressIndicatorVisible}"
                                 IsVisible="{Binding ProgressIndicatorVisible}" />
    </shell:SystemTray.ProgressIndicator>

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource PageBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Image HorizontalAlignment="Right" VerticalAlignment="Top" Source="/ApplicationIcon.png" Width="62"/>

        <!--Pivot Control-->
        <controls:Pivot x:Name="CollectionPagePivot"
                        Title="{Binding ApplicationTitle}"
                        Grid.Row="0"
                        Margin="0,0,0,0"                        
                        >
            <interactivity:Interaction.Triggers>
                <interactivity:EventTrigger EventName="SelectionChanged">
                    <gsextra:EventToCommand Command="{Binding SelectPivotCommand}" PassEventArgsToCommand="True" />
                </interactivity:EventTrigger>
            </interactivity:Interaction.Triggers>

            <controls:PivotItem Header="{Binding MoviePageName}" Name="MoviePivotItem">
                <Grid x:Name="MoviePivotGrid">
                    <ListBox x:Name="MovieListBox"
                             ItemTemplate="{StaticResource MovieItemTemplate}"
                             ItemsSource="{Binding Path=MovieCollection}"
                             ItemsPanel="{StaticResource ItemsPanelTemplate}"
                             Margin="9,-3,0,0"
                             Height="545"
                             Visibility="{Binding CollectionVisible}">
                    </ListBox>
                </Grid>
            </controls:PivotItem>
            <controls:PivotItem Header="{Binding TVPageName}" Name="TVShowPivotItem">
                <Grid x:Name="TVShowPivotGrid">
                    <ListBox x:Name="TVShowListBox"
                             ItemTemplate="{StaticResource TVShowItemTemplate}"
                             ItemsSource="{Binding Path=TVShowCollection}"
                             ItemsPanel="{StaticResource ItemsPanelTemplate}"
                             Margin="9,-3,0,0"
                             Height="545"
                             Visibility="{Binding CollectionVisible}">
                    </ListBox>
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True"
                              IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="appbarButtonRefresh" IconUri="/icons/appbar.refresh.rest.png" Text="refresh" />
            <shell:ApplicationBarIconButton x:Name="appbarButtonPrev" IconUri="/icons/appbar.back.rest.png" Text="previous" Click="appbarButton_Click" />
            <shell:ApplicationBarIconButton x:Name="appbarButoonNext" IconUri="/icons/appbar.next.rest.png" Text="next" Click="appbarButton_Click" />
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="menuItemAbout" Text="about" />
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

    <interactivity:Interaction.Behaviors>
        <wp7contribcontrolbehaviors:ApplicationBarIconButtonCommand TextKey="refresh"
                                                                    CommandBinding="{Binding RefreshCommand}" />
        <wp7contribcontrolbehaviors:ApplicationBarIconButtonCommand TextKey="previous"
                                                                    CommandBinding="{Binding PreviousCommand}" />
        <wp7contribcontrolbehaviors:ApplicationBarIconButtonCommand TextKey="next"
                                                                    CommandBinding="{Binding NextCommand}" />
        <wp7contribcontrolbehaviors:ApplicationBarMenuItemCommand TextKey="about"
                                                                  CommandBinding="{Binding AboutCommand}" />
    </interactivity:Interaction.Behaviors>

</phone:PhoneApplicationPage>